using Webshop20.AntiCorruptionLayers.Amazon.Services.Contracts;
using Webshop20.AntiCorruptionLayers.Amazon.Translators;

namespace Webshop20.AntiCorruptionLayers.Amazon.Adapters
{
    public class AmazonAdapter : IAmazonAdapter
    {
        private ICartItemTranslator carItemTranslator;
        private IDistributorFacade facade;

        public AmazonAdapter(ICartItemTranslator carItemTranslator, IDistributorFacade facade)
        {
            this.carItemTranslator = carItemTranslator;
            this.facade = facade;
        }

        public void HandleRequest(string productId, int quantity)
        {
            var carItem = carItemTranslator.ConvertToCartCreateRequestItem(productId, quantity);
            facade.PlaceOrder(carItem);
        }
    }
}